cmake_minimum_required(VERSION 3.30)
project(lua_debug C)

set(CMAKE_C_STANDARD 99)

set(src_code
        src/lapi.c src/lcode.c src/lctype.c src/ldebug.c src/ldo.c src/ldump.c src/lfunc.c src/lgc.c src/llex.c
        src/lmem.c src/lobject.c src/lopcodes.c src/lparser.c src/lstate.c src/lstring.c src/ltable.c
        src/ltm.c src/lundump.c src/lvm.c src/lzio.c
)

set(src_lib
        src/lauxlib.c src/lbaselib.c src/lbitlib.c src/lcorolib.c src/ldblib.c src/liolib.c
        src/lmathlib.c src/loslib.c src/lstrlib.c src/ltablib.c src/lutf8lib.c src/loadlib.c src/linit.c
        src/tbLib.c
)

set(src_exec src/lua.c)
set(src_comp src/luac.c)

add_executable(lua_debug ${src_code} ${src_lib} ${src_comp} ${src_exec})



set(CMAKE_RUNTIME_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/bin)
message("Copy ${CMAKE_CURRENT_SOURCE_DIR}/test.lua -> ${CMAKE_BINARY_DIR}")
add_custom_target(copy_test_lua
        COMMAND ${CMAKE_COMMAND} -E copy_if_different
        "${CMAKE_CURRENT_SOURCE_DIR}/test.lua"
        "${CMAKE_BINARY_DIR}"
        COMMENT "Copying test.lua"
)
add_dependencies(${PROJECT_NAME} copy_test_lua)
